/**
 * Copyright (C) 2011 KingCore Science & Technology CO,.LTD. All rights reserved.
 * XNS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/**
 * Copyright (C) 2002-2011 WUZEWEN. All rights reserved.
 * WUZEWEN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 * This software is the confidential and proprietary information of
 * WuZeven, Personal. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with WuZeven.
 */

package com.kingcore.director.base.ui;

import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.KeyListener;
import java.awt.event.MouseListener;

import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;

import org.apache.log4j.Logger;

import wzw.sql.DatabaseOperator;
import wzw.swing.table.PlainTable;
import wzw.swing.tree.PlainTree;

/**
 * <p>进一步封装更多成员，这里是一种尝试，更加快速开发界面对象，最好都统一到 DirectorPanel，
 *      PlainDirectorPanel<--DirectorPanel<--JPanel .</p>
 * @author Zeven/wzw on Jul 23, 2011
 * @version	1.0
 * @see		Object#equals(java.lang.Object)
 * @since	JDK5
 */

public abstract class PlainDirectorPanel extends DirectorPanel implements DatabaseOperator,
		ActionListener, MouseListener, KeyListener{

	private final static Logger log = Logger.getLogger(PlainDirectorPanel.class);

	public final static int MainSplitPane_Left_Width = 200;
	
	public PlainDirectorPanel(DirectorFrame baseFrame) {
		super(baseFrame);
		initializeInterface();
	}

	@Override
	public void refreshView() {
		super.refreshView();
		
		setStatus(StatusBar_Index_One, currentStatusInfor);
	}
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	protected void initializeInterface() {
		// BorderLayout ...
		this.setLayout( new BorderLayout() );
		//this.add( getMainNorthPanel(), BorderLayout.NORTH);
		this.add( getMainSplitPane(), BorderLayout.CENTER);
		
		//this.add(new JLabel("提供云服务-程序分类，热门程序推荐下载，并且与本地文件、FavoriteFiles相关联。"), BorderLayout.NORTH);
	}

	private JSplitPane mainSplitPane = null;
	protected JSplitPane getMainSplitPane(){
		if (mainSplitPane==null) {
			mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false);
			//mainSplitPane.add(getLeftScrollPane(),0);
			//mainSplitPane.add(getRightSplitPane(),1);
			mainSplitPane.setOneTouchExpandable(true);
			mainSplitPane.setDividerSize(6);
			mainSplitPane.setDividerLocation( MainSplitPane_Left_Width );  //200);
		}
		return mainSplitPane;
	}
	

	private JScrollPane leftScrollPane = null;
	/**
	 * This method initializes leftScrollPane
	 *
	 * @return javax.swing.JScrollPane
	 */
	protected JScrollPane getLeftScrollPane() {
		if (leftScrollPane == null) {
			leftScrollPane = new JScrollPane();
			//leftScrollPanel.setBounds(new java.awt.Rectangle(2, this.clientTop,150, this.clientHeight));
			leftScrollPane.setViewportView( getMainTree() );	//getJt_tree()
		}
		return leftScrollPane;
	}
	

	JSplitPane rightSplitPane = null;
	protected JSplitPane getRightSplitPane() {
		if(rightSplitPane==null){
			rightSplitPane = new JSplitPane();

			rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false);
			rightSplitPane.setBorder(null);	
			//rightPanel.add(getCommonSearchPanel(), JSplitPane.TOP );
			rightSplitPane.add(getRightScrollPane(), JSplitPane.BOTTOM );	
			rightSplitPane.setOneTouchExpandable(true);
			rightSplitPane.setDividerSize(0);
			rightSplitPane.setDividerLocation( 0 ); //Main.MainFrame_Size_Height-180
			
		}
		return rightSplitPane;
	}
	

	private JScrollPane rightScrollPane = null;
	/**
	 * This method initializes jPanel
	 *
	 * @return javax.swing.JPanel
	 */
	protected JScrollPane getRightScrollPane() {
		if (rightScrollPane == null) {
			rightScrollPane = new JScrollPane();
			//rightScrollPanel.setBounds(new java.awt.Rectangle(158,this.clientTop,432, this.clientHeight));
			
			//rightScrollPanel.setLayout(new BorderLayout());
			//rightScrollPanel.setLayout( new BorderLayout() );
			rightScrollPane.setViewportView( getMainTable() ); //getTable()
			//rightScrollPanel.setBackground(Color.gray);
		}
		return rightScrollPane;
	}
	

	protected JTable mainTable = null;
	/**
	 * This method initializes table	
	 * 	
	 * @return javax.swing.JTable	
	 */
	protected JTable getMainTable(){
		if (mainTable==null) {
			mainTable = new PlainTable();
		}
		return mainTable;
		
	}
	
	/**
	 * 
	 */
	protected abstract PlainTree getMainTree();
//	{
//		if (mainTree  == null) { 
//			mainTree = new JTree();
//		}
//		return mainTree;
//	}

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * <p>java方法的说明...</p>
	 * @author Zeven on Jul 23, 2011
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
